using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Move : MonoBehaviour
{
    public int speed;
    private Animator _animator;

    // Start is called before the first frame update
    void Start()
    {
        // 
        _animator = this.GetComponent<Animator>();
    }

    // Update is called once per frame
    void Update()
    {
        var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");
        _animator.SetFloat("Move", 0);
        if (Math.Abs(x) > 0 || Math.Abs(y) > 0)
        {
            _animator.SetFloat("X", x);
            _animator.SetFloat("Y", y);
            _animator.SetFloat("Move", 1);
        }
    }

    void FixedUpdate()
    {
        var x = Input.GetAxis("Horizontal");
        var y = Input.GetAxis("Vertical");
        transform.Translate(new Vector3(x * speed * Time.deltaTime, y * speed * Time.deltaTime, 0));
    }
}